package com.origin.niuke.simulation;

/**
 * @author yzh
 * @version 1.0
 * @date 2022/4/27 12:22
 * 大数加法
 * 算法：字符串 + 模拟
 */
public class NC1 {

    public String solve (String s, String t) {
        // write code here
        int carry = 0, l1 = s.length(), l2 = t.length();
        StringBuilder ans = new StringBuilder();
        while (l1 > 0 || l2 > 0) {
            int a = l1 > 0 ? s.charAt(--l1) - '0' : 0;
            int b = l2 > 0 ? t.charAt(--l2) - '0' : 0;
            int tmp = a + b + carry;
            ans.append(tmp % 10);
            carry = tmp / 10;
        }
        if (carry == 1) ans.append(1);
        return ans.reverse().toString();
    }

}
